﻿using System;
using System.Windows.Media;

namespace CSharp.Libs.WPF.UserControls
{
    public class KocAllianceListItem : ViewModelBase
    {
        #region declarations
        private String _strAllianceId = "";
        private String _strName = "";
        private String _strMembersCount = "";
        private String _strMight = "";
        private String _strRanking = "";
        private String _strHostUserId = "";
        private String _strHost = "";
        private String _strHostGenderAndName = "";
        private String _strFounderUserId = "";
        private String _strFounderName = "";
        private String _strFounderGenderAndName = "";
        private SolidColorBrush _scbColor = Brushes.Black;

        private Int64 _intAvergeMight = 0;
        private String _strAvergeMight = "";
        #endregion



        #region constructor / terminator
        public KocAllianceListItem()
        {
        }

        public KocAllianceListItem(
            String AllianceId,
            String Name,
            String MembersCount,
            String Might,
            String Ranking,
            String HostUserId,
            String Host,
            String HostGenderAndName,
            String FounderUserId,
            String FounderName,
            String FounderGenderAndName)
        {
            _calcAverageMight();
        }

        ~KocAllianceListItem()
        {
        }
        #endregion



        #region private functions
        private void _calcAverageMight()
        {
            try
            {
                _intAvergeMight = -1;

                Int64 intMemberCount = 0;
                Int64.TryParse(_strMembersCount, out intMemberCount);
                Int64 intMight = 0;
                Int64.TryParse(_strMight.Replace(".", ""), out intMight);

                if (intMight >= intMemberCount)
                {
                    _intAvergeMight = intMight / intMemberCount;
                    _strAvergeMight = _intAvergeMight.ToString("0,000");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion



        #region interface
        #region properties
        public String AllianceId
        {
            get
            {
                return _strAllianceId;
            }
            set
            {
                _strAllianceId = value;
                OnPropertyChanged("AllianceId");
            }
        }

        public String Name
        {
            get
            {
                return _strName;
            }
            set
            {
                _strName = value;
                OnPropertyChanged("Name");
            }
        }

        public String MembersCount
        {
            get
            {
                return _strMembersCount;
            }
            set
            {
                _strMembersCount = value;
                _calcAverageMight();
                OnPropertyChanged("MembersCount");
            }
        }

        public String Might
        {
            get
            {
                return _strMight;
            }
            set
            {
                _strMight = value;
                _calcAverageMight();
                OnPropertyChanged("Might");
            }
        }

        public String Ranking
        {
            get
            {
                return _strRanking;
            }
            set
            {
                _strRanking = value;
                OnPropertyChanged("Ranking");
            }
        }

        public String HostUserId
        {
            get
            {
                return _strHostUserId;
            }
            set
            {
                _strHostUserId = value;
                OnPropertyChanged("HostUserId");
            }
        }
        
        public String Host
        {
            get
            {
                return _strHost;
            }
            set
            {
                _strHost = value;
                OnPropertyChanged("Host");
            }
        }

        public String HostGenderAndName
        {
            get
            {
                return _strHostGenderAndName;
            }
            set
            {
                _strHostGenderAndName = value;
                OnPropertyChanged("HostGenderAndName");
            }
        }

        public String FounderUserId
        {
            get
            {
                return _strFounderUserId;
            }
            set
            {
                _strFounderUserId = value;
                OnPropertyChanged("FounderUserId");
            }
        }
        
        public String FounderName
        {
            get
            {
                return _strFounderName;
            }
            set
            {
                _strFounderName = value;
                OnPropertyChanged("FounderName");
            }
        }

        public String FounderGenderAndName
        {
            get
            {
                return _strFounderGenderAndName;
            }
            set
            {
                _strFounderGenderAndName = value;
                OnPropertyChanged("FounderGenderAndName");
            }
        }

        public SolidColorBrush Color
        {
            get
            {
                return _scbColor;
            }
            set
            {
                _scbColor = value;
                OnPropertyChanged("Color");
            }
        }

        public Int64 AverageMightNumber
        {
            get
            {
                return _intAvergeMight;
            }
        }

        public String AverageMight
        {
            get
            {
                return _strAvergeMight;
            }
        }
        #endregion

        #region methods
        #endregion
        #endregion
    }
}
